home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_118 / wiredemo / tech.doc < prev    next >
Text File  |  1992-05-06  |  4KB  |  97 lines

  1. To: bryce@hoser.berkeley.edu
  2. Subject: Re: Here's a Demo
  3. Precedence: special-delivery
  4.  
  5.     Unless you have a better ball that is the final version (as far
  6. as the contest goes).  Here is a tech description.  Source is also
  7. available, of course.  (I guess I'll bring the source to the BADGE meeting
  8. on the 15th).... I'm not sure if Tom wants a tech description on how the
  9. demo was created, but if he does you can send him the one below.  Otherwise
  10. it is for your curiosity and reading pleasure.
  11.  
  12. --------------------------------------------------------------------------
  13. TECHNICAL DESCRIPTION OF WIREDEMO FOLLOWS
  14. --------------------------------------------------------------------------
  15.  
  16.  
  17. DISPLAY
  18.  
  19. Camera:     x,y,z of camera  (coordinate range -16384 to 16383)
  20.         x,y,z of center  (coordinate range -16384 to 16383)
  21.  
  22. Note that one degree of freedom is missing.... the rotational angle of the
  23. vector.   This means that if, say, you were looking exactly downward from
  24. above you would have no control over the rotation of the view you were
  25. seeing.  As far as this demo goes, we do not care, and this cuts the point
  26. calculation time in half.
  27.  
  28. The THETA and PHI between the vector (center,camera) and the x axis is
  29. calculated just once per frame, as are various trig functions of THETA and
  30. PHI.  Angles are stored in the range 0x0000-0xFFFF (0 to twopi) and the
  31. results of COS and SIN are in the range -16384 to 16384 (-1 to 1).  This
  32. version of the demo uses floating point calculations for COS/SIN/ATAN/RANGE
  33. and then converts to integers.    Future versions will simply use lookup tables.
  34.  
  35. For each point (All points are 16 bit integers.  Calculations utilize 32 bit
  36. intermediate quantities):
  37.     *Translate point by -CenterX,-CenterY,-CenterZ (camera center point),
  38.      as well as the object's X,Y,Z coordinate.  This is effectively a
  39.      single subtraction per x,y,z.    Note that translating an object
  40.      relative to the world takes no extra CPU and is absorbed in
  41.      translating it to the camera center.
  42.     *Rotate the point by -THETA(xy),-PHI(xz).  The equations were
  43.      generated from a standard 3D rotation matrix.    It takes 6 or 7
  44.      short (MULS) multiplications and as many additions.  All trig
  45.      functions are precomputed (once per frame).
  46.  
  47.      To multiply a point by a COS/SIN function result we do the equivalent
  48.      of a MULS, then shift the 32 bit result right by 15 to fix the
  49.      decimal point.
  50.  
  51.     *X is now depth, Z vertical, and Y -horizonal in our camera
  52.      coordinate system.  Swap coordinate elements around so Z is depth,
  53.      X and Y are horizonal and vertical components (no CPU time.. just
  54.      a matter of proper assignment).  This is just so I don't get confused.
  55.  
  56.     *Generate a false perspective by dividing X and Y by some function of Z
  57.      (two multiplications and two divisions total)
  58.  
  59. Once the points are calculated for an object each line segment must be drawn.
  60. We can't preclip the points because multiple line segments might use them in
  61. different directions:
  62.  
  63.     -Clip the line segment on the left, right, top, bottom, and back
  64.      (Z < 0).... relatively trivial but takes almost as much time as
  65.      point calculation.
  66.  
  67.     -Display in Screen's RastPort (since we do our own clipping).
  68.  
  69.  
  70. ANIMATION
  71.  
  72.     Animation is accomplished by (A) moving the ball relative to the
  73.     world, (B) moving the camera center, and (C) moving the camera
  74.     itself.  The AMIGA object does not move.
  75.  
  76.     The camera center, camera, and ball are given velocity and
  77.     acceleration components.  The camera center attempts to track the
  78.     ball, and the camera attempts to track the camera center.  The
  79.     three items are given different acceleration characteristics to
  80.     facilitate the DEMO.
  81.  
  82.     The ball is effected by gravity but I cheat when it hits Z=0...
  83.     we give it a 'boost' upward so it bounces to different heights.
  84.     The X and Y velocities of the ball are constant.
  85.  
  86. DISPLAY
  87.  
  88.     A two bitplane custom screen is used.  Smooth animation is obtained
  89.     by double buffering via the color pallette... draw into one bit plane
  90.     while displaying the other, then turn on the second bitplane, clear
  91.     the first, and draw into the first, etc....  This is accomplished by
  92.     SetRGB4() ,RP->Mask = xx, SetAPen(), and SetRast(Rp,0) calls once per
  93.     frame.
  94.  
  95.                             -Matt
  96.  
  97.